home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Communications / pcomm / Source / s_gen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  4.3 KB  |  152 lines

  1. /*
  2.  * Display the general setup, query for changes.  A non-zero return code
  3.  * means something was changed.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <curses.h>
  8. #include "config.h"
  9. #include "misc.h"
  10. #include "param.h"
  11.  
  12. int
  13. gen_setup()
  14. {
  15.     extern char *v_yes[];
  16.     WINDOW *g_win, *newwin();
  17.     int i, num, ret_code;
  18.     char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  19.     char *str_rep();
  20.     void line_set();
  21.     static char *v_abort[3] = {"KEEP", "DELETE", NULL};
  22.  
  23.     g_win = newwin(23, 80, 0, 0);
  24.  
  25.     horizontal(g_win, 0, 0, 32);
  26.     mvwattrstr(g_win, 0, 33, A_BOLD, "General Setup");
  27.     horizontal(g_win, 0, 47, 32);
  28.     mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  29.     mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  30.     mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  31.     mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  32.     mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  33.     mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  34.     mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  35.     mvwprintw(g_win, 12, 22, "8) Break character ........ %c", param->brk_char);
  36.     mvwprintw(g_win, 14, 22, "9) Aborted downloads ...... %s", param->abort);
  37.     mvwprintw(g_win, 16, 21, "10) Connect delay (sec) .... %d", param->c_delay);
  38.     mvwprintw(g_win, 17, 21, "11) Redial delay (sec) ..... %d", param->r_delay);
  39.     horizontal(g_win, 19, 0, 80);
  40.     mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  41.     mvwaddstr(g_win, 20, 58, "Press <ESC> to return");
  42.     wmove(g_win, 20, 12);
  43.     touchwin(g_win);
  44.     wrefresh(g_win);
  45.                     /* get the option number */
  46.     ret_code = 0;
  47.     while ((i = get_num(g_win, 2)) != -1) {
  48.         switch (i) {
  49.             case 1:
  50.                 if ((ans = str_prompt(g_win, 3, 50, "Default log file", "")) != NULL) {
  51.                     param->logfile = str_rep(param->logfile, ans);
  52.                     ret_code++;
  53.                 }
  54.                 break;
  55.             case 2:
  56.                 if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", "")) != NULL) {
  57.                     param->dumpfile = str_rep(param->dumpfile, ans);
  58.                     ret_code++;
  59.                 }
  60.                 break;
  61.             case 3:
  62.                 if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit?", v_yes)) != NULL) {
  63.                     param->strip = str_rep(param->strip, ans);
  64.                     line_set();
  65.                     ret_code++;
  66.                 }
  67.                 break;
  68.             case 4:
  69.                 if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != '\0') {
  70.                     param->pause_char = c;
  71.                     ret_code++;
  72.                 }
  73.                 break;
  74.             case 5:
  75.                 if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != '\0') {
  76.                     param->cr_char = c;
  77.                     ret_code++;
  78.                 }
  79.                 break;
  80.             case 6:
  81.                 if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != '\0') {
  82.                     param->ctrl_char = c;
  83.                     ret_code++;
  84.                 }
  85.                 break;
  86.             case 7:
  87.                 if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != '\0') {
  88.                     param->esc_char = c;
  89.                     ret_code++;
  90.                 }
  91.                 break;
  92.             case 8:
  93.                 if ((c = chr_prompt(g_win, 12, 50, "Break character", "")) != '\0') {
  94.                     param->brk_char = c;
  95.                     ret_code++;
  96.                 }
  97.                 break;
  98.             case 9:
  99.                 if ((ans = menu_prompt(g_win, 14, 50, "Aborted downloads", v_abort)) != NULL) {
  100.                     param->abort = str_rep(param->abort, ans);
  101.                     ret_code++;
  102.                 }
  103.                 break;
  104.             case 10:
  105.                 if ((num = num_prompt(g_win, 16, 50, "Connect delay time", "(in seconds)")) != -1) {
  106.                     if (num > MAX_CDELAY || num < MIN_CDELAY) {
  107.                         beep();
  108.                     /* some reasonable range of values */
  109.                         if (num < MIN_CDELAY)
  110.                             num = MIN_CDELAY;
  111.                         else
  112.                             num = MAX_CDELAY;
  113.                         mvwaddstr(g_win, 16, 50, "   ");
  114.                         wrefresh(g_win);
  115.                         mvwattrnum(g_win, 16, 50, A_BOLD, num);
  116.                         wrefresh(g_win);
  117.                     }
  118.                     param->c_delay = num;
  119.                     ret_code++;
  120.                 }
  121.                 break;
  122.             case 11:
  123.                 if ((num = num_prompt(g_win, 17, 50, "Redial delay time", "(in seconds)")) != -1) {
  124.                     if (num > MAX_PAUSE || num < MIN_PAUSE) {
  125.                         beep();
  126.                     /* some reasonable range */
  127.                         if (num < MIN_PAUSE)
  128.                             num = MIN_PAUSE;
  129.                         else
  130.                             num = MAX_PAUSE;
  131.                         mvwaddstr(g_win, 17, 50, "    ");
  132.                         wrefresh(g_win);
  133.                         mvwattrnum(g_win, 17, 50, A_BOLD, num);
  134.                         wrefresh(g_win);
  135.                     }
  136.                     param->r_delay = num;
  137.                     ret_code++;
  138.                 }
  139.                 break;
  140.             default:
  141.                 beep();
  142.         }
  143.         mvwaddstr(g_win, 20, 12, "  ");
  144.         clear_line(g_win, 21, 0, FALSE);
  145.         clear_line(g_win, 22, 0, FALSE);
  146.         wmove(g_win, 20, 12);
  147.         wrefresh(g_win);
  148.     }
  149.     delwin(g_win);
  150.     return(ret_code);
  151. }
  152.